package com.travel.recommend.controller;

import java.util.Arrays;
import java.util.Map;

import com.travel.common.to.UserBehaviorWeightTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.travel.recommend.entity.UserBehaviorWeightEntity;
import com.travel.recommend.service.UserBehaviorWeightService;
import com.travel.common.utils.PageUtils;
import com.travel.common.utils.R;



/**
 * 
 *
 * @author lxw
 * @email lxw@gmail.com
 * @date 2024-01-23 09:52:06
 */
@RestController
@RequestMapping("recommend/userbehaviorweight")
public class UserBehaviorWeightController {
    @Autowired
    private UserBehaviorWeightService userBehaviorWeightService;

    /**
     * 获取正在使用的用户行为权重配置信息
     * @return
     */
    @RequestMapping("/getUserBehaviorWeight")
    public UserBehaviorWeightTo getUserBehaviorWeight(){
        return userBehaviorWeightService.getUserBehaviorWeight();

    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("recommend:userbehaviorweight:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userBehaviorWeightService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{userBehaviorWeightId}")
    //@RequiresPermissions("recommend:userbehaviorweight:info")
    public R info(@PathVariable("userBehaviorWeightId") Integer userBehaviorWeightId){
		UserBehaviorWeightEntity userBehaviorWeight = userBehaviorWeightService.getById(userBehaviorWeightId);

        return R.ok().put("userBehaviorWeight", userBehaviorWeight);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("recommend:userbehaviorweight:save")
    public R save(@RequestBody UserBehaviorWeightEntity userBehaviorWeight){
		userBehaviorWeightService.save(userBehaviorWeight);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("recommend:userbehaviorweight:update")
    public R update(@RequestBody UserBehaviorWeightEntity userBehaviorWeight){
		userBehaviorWeightService.updateById(userBehaviorWeight);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("recommend:userbehaviorweight:delete")
    public R delete(@RequestBody Integer[] userBehaviorWeightIds){
		userBehaviorWeightService.removeByIds(Arrays.asList(userBehaviorWeightIds));

        return R.ok();
    }

}
